﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ACH
{
    public partial class CreateTrainingParticipant : Form
    {
        string _training;

        public CreateTrainingParticipant(string training)
        {
            InitializeComponent();
            _training = training;
        }

        private void CreateTrainingParticipant_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'aCHDataSet.TrainingParticipantPositions' table. You can move, or remove it, as needed.
            this.trainingParticipantPositionsTableAdapter.Fill(this.aCHDataSet.TrainingParticipantPositions);
            // TODO: This line of code loads data into the 'aCHDataSet.TrainingParticipantPositions' table. You can move, or remove it, as needed.
            this.trainingParticipantPositionsTableAdapter.Fill(this.aCHDataSet.TrainingParticipantPositions);
            // TODO: This line of code loads data into the 'aCHDataSet.Members' table. You can move, or remove it, as needed.
            this.membersTableAdapter.Fill(this.aCHDataSet.Members);
            // TODO: This line of code loads data into the 'aCHDataSet.Trainings' table. You can move, or remove it, as needed.
            this.trainingsTableAdapter.Fill(this.aCHDataSet.Trainings);

            int position = trainingsBindingSource.Find("ID", _training);
            if (position >= 0)
                trainingsBindingSource.Position = position;
        }

        private void btnCreateParticipant_Click(object sender, EventArgs e)
        {
            ACHDataSetTableAdapters.TrainingParticipantsTableAdapter log = new ACHDataSetTableAdapters.TrainingParticipantsTableAdapter();
            log.Insert(Guid.NewGuid().ToString(), ((txtTrainingName.DataBindings[0].DataSource as BindingSource).Current as DataRowView)["ID"].ToString(),
                (cmbMembers.SelectedValue as DataRowView)["ID"].ToString(), (cmbPosition.SelectedValue as DataRowView)["ID"].ToString(), dateStart.Value,
                dateEnd.Value, DateTime.Now, DateTime.Now, "PAUL", "PAUL");
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
    }
}
